package 反射第二遍.demo20;

import java.lang.reflect.Method;

/**
 * @author wql
 * @version 1.0
 * @date 2022/10/27 15:56
 */

public class Test {
    public static void main(String[] args)throws Exception {
        Class<hehe> heheClass = hehe.class;
        Method play = heheClass.getDeclaredMethod("play", String.class, Integer.class);
        System.out.println("play = " + play);
        Method[] declaredMethods = heheClass.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            System.out.println("declaredMethod = " + declaredMethod);
        }
        Method eat = heheClass.getMethod("eat");
        System.out.println("eat = " + eat);
        Method[] methods = heheClass.getMethods();
        for (Method method : methods) {
            System.out.println(method);
        }
    }
}
class  haha{
    public void eat(){
        System.out.println("haha的eat方法");
    }
    public void drink(){
        System.out.println("haha的drink方法");
    }
}
class hehe extends haha{
    public void noeat(){
        System.out.println("hehe的noeat方法");
    }
    public void play(String name,Integer num){
        System.out.println("hehe的paly方法"+name);
    }
}
